package Year22_Month03.day01;

import java.util.Scanner;

public class Main1 {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int key = keyFunc(a);
        int count = 0;
        while(a != key) {
            if (key > a) {
                a++;
                count++;
            } else {
                a--;
                count++;
            }
        }
        System.out.println(count);
    }

    public static int keyFunc(int key){
        int i = 0;
        int j = 1;
        int a = 1;
        while(j < key){
            a = i + j;
            i = j;
            j = a;
        }

        return j-key > key - i ? i : j;
    }
}

